package com.cmc.cloud.cmclink.doc.controller.admin.multimodaltransport;

import com.cmc.cloud.cmclink.doc.api.document.emums.ExImTypeEnum;
import com.cmc.cloud.cmclink.doc.constants.UrlConstants;
import com.cmc.cloud.cmclink.doc.service.multimodaltransport.BlnoLinerPreService;
import com.cmc.cloud.cmclink.doc.vo.multimodaltransport.blnolinerpre.*;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.common.pojo.PageResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 提单前程支线船名航次维护
 *
 * @author 申天青
 * @date 2025/10/20
 */
@Tag(description = "提单前程支线船名航次维护", name = "提单前程支线船名航次维护")
@RestController
@RequestMapping(UrlConstants.APPLICATION_URL + "/blno-liner-pre")
public class BlnoLinerPreController {

    @Resource
    private BlnoLinerPreService blnoLinerPreService;

    @Operation(summary = "ex Set Pre")
    @PostMapping("/ex/update")
    public CommonResult<List<UpdateBlnoLinerPreCheckMsgReqVO>>
    setExLinerPre(@Valid @RequestBody UpdateBlnoLinerPreAllReqVO updateBlnoLinerPreAllReqVO) {
        return CommonResult.success(blnoLinerPreService.setLinerPre(updateBlnoLinerPreAllReqVO,ExImTypeEnum.EX));
    }

    @Operation(summary = "ex Set Pre Check 校验原驳船航次是否为“TBA”或空值，非TBA且非空值时做出提示：”舱单已绑定驳船XXX（原驳船船名航次），是否重新绑定？”,是则继续。")
    @PostMapping("/ex/check")
    public CommonResult<List<UpdateBlnoLinerPreCheckMsgReqVO>>
    checkExBlnoBarge(@Valid @RequestBody CheckBlnoLinerPreAllReqVO updateBlnoLinerPreAllReqVO) {
        return CommonResult.success(blnoLinerPreService.checkLinerPre(updateBlnoLinerPreAllReqVO,ExImTypeEnum.EX));
    }

    @Operation(summary = "ex 获得分页")
    @PostMapping("/ex/page")
    public CommonResult<PageResult<BlnoLinerPreRespVO>>
    getExBlnoBargePage(@Valid @RequestBody BlnoLinerPrePageReqVO pageVo) {
        PageResult<BlnoLinerPreRespVO> pageResult = blnoLinerPreService.getBlnoLinerPrePage(pageVo,ExImTypeEnum.EX);
        return CommonResult.success(pageResult);
    }
    @Operation(summary = "im Set Pre")
    @PostMapping("/im/update")
    public CommonResult<List<UpdateBlnoLinerPreCheckMsgReqVO>>
    setImBlnoBarge(@Valid @RequestBody UpdateBlnoLinerPreAllReqVO updateBlnoLinerPreAllReqVO) {
        return CommonResult.success(blnoLinerPreService.setLinerPre(updateBlnoLinerPreAllReqVO,ExImTypeEnum.IM));
    }

    @Operation(summary = "im Set Pre Check")
    @PostMapping("/im/check")
    public CommonResult<List<UpdateBlnoLinerPreCheckMsgReqVO>>
    checkImBlnoBarge(@Valid @RequestBody CheckBlnoLinerPreAllReqVO updateBlnoLinerPreAllReqVO) {
        return CommonResult.success(blnoLinerPreService.checkLinerPre(updateBlnoLinerPreAllReqVO,ExImTypeEnum.IM));
    }

    @Operation(summary = "im 获得分页")
    @PostMapping("/im/page")
    public CommonResult<PageResult<BlnoLinerPreRespVO>>
    getImBlnoBargePage(@Valid @RequestBody BlnoLinerPrePageReqVO pageVo) {
        PageResult<BlnoLinerPreRespVO> pageResult = blnoLinerPreService.getBlnoLinerPrePage(pageVo,ExImTypeEnum.IM);
        return CommonResult.success(pageResult);
    }
}
